<!-- 描述病情页面 -->
<template>
  <view class="msBox">
    <TopNavigation leftTitle="描述病情" rightTitle="" />
    <view class="items-center w-[95%] flex" style="">
      <img
        v-if="selectId"
        src="@/static/exports/doctor_portrait@1x.png"
        class="w-130rpx h-130rpx"
      />
      <img v-else src="@/static/exports/doctor_portrait@1x.png" class="w-130rpx h-130rpx" />
      <view class="ml-4">
        <wd-text
          custom-class="jstpBox"
          :text="selectId ? name : '极速图文(自动分配医生)'"
        ></wd-text>
        <view class="mx-0 my-10rpx bg-[#FAFAFA]" style="padding: 20rpx">
          <wd-text
            text="请描述你的疾病或症状、是否用药、就诊经历，需要我提供什么样的帮助。"
            custom-class="tswbBox"
          ></wd-text>
        </view>
        <text style="font-size: 18rpx; color: #bababa">内容仅医生可见</text>
      </view>
    </view>
    <view class="h-1rpx mx-0 my-15rpx w-[100%]" style="background-color: #f5f5f5"></view>
    <wd-textarea
      v-model="value"
      placeholder="请详细描述您的病情"
      custom-class="dhwbyBox"
      size="small"
      auto-height
      :no-border="true"
    />
    <text class="text-25rpx mb-6rpx w-[95%]" style="">本次患病多久了</text>
    <view class="w-[95%] mb-5">
      <view class="mt-15rpx w-[100%] flex" style="">
        <view v-for="i in list">
          <button :class="current == i ? 'buttonBn' : 'buttonAn'" @click="current = i">
            {{ i }}
          </button>
        </view>
      </view>
    </view>
    <text class="text-25rpx mb-6rpx w-[95%]" style="">此次病情是否去医院就诊过</text>
    <view class="w-[95%] mb-5">
      <view class="mt-15rpx w-[100%] flex" style="">
        <view v-for="i in list1">
          <button :class="current1 == i ? 'buttonBn' : 'buttonAn'" @click="current1 = i">
            {{ i }}
          </button>
        </view>
      </view>
    </view>
    <view class="mx-0 my-20rpx items-center flex w-[95%]" style="">
      <wd-upload
        :file-list="fileList"
        :limit="9"
        action="https://mockapi.eolink.com/zhTuw2P8c29bc981a741931bdd86eb04dc1e8fd64865cb5/upload"
        @change="handleChange"
      />
      <wd-text
        v-if="fileList.length == 0"
        text="上传检查报告或患处照片（最多9张）"
        custom-class="sctpBox"
      ></wd-text>
    </view>
    <wd-toast />
    <button
      class="items-center justify-center flex tracking-0rpx leading-32rpx text-32rpx font-medium text-[#FFFFFF] h-88rpx w-690rpx rounded-[44px] custom-shadow bg-[#16C2A3] mt-10rpx"
      @click="tzHzxx"
    >
      下一步
    </button>
  </view>
</template>

<script lang="ts" setup>
import TopNavigation from "@/components/TopNavigation.vue";
import { useToast } from "wot-design-uni";
import { LoginPinia } from "@/store/modules/Login";
const loginValue = LoginPinia();
// 选择的医生头像
const avatar = ref<string>("");
// 选择的医生name
const name = ref<string>("");
// 判断是从哪个页面过来的
const selectId = ref();
const value = ref<string>("");

const list = ref<string[]>(["一周内", "一月内", "半年内", "大于半年"]);
const current = ref("");

const list1 = ref<string[]>(["就诊过", "没就诊过"]);
const current1 = ref("");

const fileList = ref<any[]>([]);
const fileListA = [""];
const toast = useToast();
function handleChange({ fileList: files }: { fileList: any[] }) {
  fileList.value = files;
}
// 咨询医生的数据
const doctorData = ref<any>({
  commentId: "1",
  createTime: 1737635185,
  department: "内分泌科",
  hospital: "北京协和医院",
  isDeleted: 0,
  level: "三甲",
  name: "李二狗",
  num: "1.2",
  online: true,
  price: "49",
  professionalTitle: "副主任医师",
  specialties: "小儿呼吸、小儿消化、儿童过敏",
  star: "4.9",
  updateTime: 1737635185,
  __v: 0,
  _id: "6792357128059b7a78ec",
});

function tzHzxx() {
  if (value.value !== "" && current.value !== "" && current1.value !== "") {
    const obj = {
      description: value.value,
      time: current.value,
      record: current1.value,
      docName: doctorData.value.name,
      professionalTitle: doctorData.value.professionalTitle,
      department: doctorData.value.department,
      hospital: doctorData.value.hospital,
      paymentType: "图文问诊",
      img: fileListA,
      money: Number(doctorData.value.price),
      coupon: 10,
      points: 1,
    };
    loginValue.tjZc(obj);
    uni.navigateTo({ url: "/pages/selectPatient/index" });
  } else {
    toast.error("轻填写完信息后再进行");
  }
}
import DoctorAPI from "@/api/system/doctor";

onLoad(async (option) => {
  if (option && option.id !== undefined) {
    selectId.value = option.id;
    if (option.id) {
      const res = await DoctorAPI.getDoctorInfo(option.id);
      if (res !== undefined) {
        doctorData.value = res;
        avatar.value = res.price;
        name.value = res.name;
        loginValue.addZixun(res.price);
      }
    }
  }
});
console.log(doctorData.value);
</script>

<style lang="scss" scoped>
.msBox {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100vh;
  background-color: #fff;
}
.buttonAn {
  width: 136rpx;
  height: 64rpx;
  margin-right: 20rpx;
  font-size: 25rpx;
  background-color: #fafafa;
}
.buttonBn {
  width: 136rpx;
  height: 64rpx;
  margin-right: 20rpx;
  font-size: 25rpx;
  color: #4fbeb2;
  background-color: #eaf8f6;
  border: 1px solid #4fbeb2;
}
.jstpBox {
  font-size: 32rpx !important;
  font-weight: medium !important;
  line-height: 48rpx !important;
  color: #121826 !important;
  text-align: left;
  letter-spacing: 0px;
}
.tswbBox {
  font-size: 26rpx !important;
  font-weight: light !important;
  line-height: 40rpx !important;
  color: #6f6f6f !important;
  text-align: left;
  letter-spacing: 0px;
}
.sctpBox {
  margin-left: 41rpx;
  font-size: 22rpx !important;
  font-weight: light !important;
  line-height: 32rpx !important;
  color: #979797 !important;
  text-align: left;
  letter-spacing: 0px;
}
.dhwbyBox {
  width: 90%;
  height: 259rpx;
}
</style>
